import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @author liuchaoqun
 * @date 2022/7/15
 * @Description
 */
public class Split {
    public static void main(String[] args) {
        String summary = "7月15日天津基地1";
        Integer year = LocalDate.now().getYear();
        List<String> list = new ArrayList(Arrays.asList(summary.split("日")));
        list.remove(list.size() - 1);
        // 第一个元素为日第二个元素为月
        List<String> dayAndMonth = new ArrayList<>(Arrays.asList(list.get(0).split("月")));
        String compareTime = year + "-" + (dayAndMonth.get(0).length() > 1 ? dayAndMonth.get(0) : "0" + dayAndMonth.get(0)) + "-" + (dayAndMonth.get(1).length() > 1 ? dayAndMonth.get(1) : "0" + dayAndMonth.get(1));
        LocalDate now = LocalDateTime.now().toLocalDate();
        System.out.println(now);
        LocalDate cTime = LocalDate.parse(compareTime);
        System.out.println(cTime);
        if (cTime.isEqual(now)) {
            System.out.println("对上日期了");
        }

        String spanTime = "7月15日至16日天津基地1";
        List<String> span = new ArrayList(Arrays.asList(spanTime.split("日")));
        span.remove(span.size() - 1);
        List<String> monthAndStart = new ArrayList<>(Arrays.asList(span.get(0).split("月")));
        String dayEnd = span.get(1).replace("至", "");
        String startDay = year + "-" + (monthAndStart.get(0).length() > 1 ? monthAndStart.get(0) : "0" + monthAndStart.get(0)) + "-" + (monthAndStart.get(1).length() > 1 ? monthAndStart.get(1) : "0" + monthAndStart.get(1));
        String endDay = year + "-" + (monthAndStart.get(0).length() > 1 ? monthAndStart.get(0) : "0" + monthAndStart.get(0)) + "-" + (dayEnd.length() > 1 ? dayEnd : "0" + dayEnd);
        LocalDate startLocalDate = LocalDate.parse(startDay).minusDays(1L);
        LocalDate endLocalDate = LocalDate.parse(endDay).plusDays(1L);

        if (now.isAfter(startLocalDate) && now.isBefore(endLocalDate)) {

            System.out.println("在日期范围内");

        }
        System.out.println(startLocalDate + "----" + endLocalDate);


    }
}
